import entity.Employee;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.Predicate;
import java.util.function.Supplier;

public class LambdaPractice {

    private static List<Employee> LIST = new ArrayList<>();
    private static List<String> STRING_LIST = Arrays.asList("杰哥","阿伟","小红");
    static {
        LIST.add(new Employee("杰哥",30,"一个光头","江苏"));
        LIST.add(new Employee("阿伟",20,"一个少年","江苏"));
        LIST.add(new Employee("小黄",24,"写Java的","浙江"));
        LIST.add(new Employee("小红红",24,"写Python的","浙江"));
        LIST.add(new Employee("小黑",28,"写Bug的","上海"));
        LIST.add(new Employee("小绿人",26,"写React的","上海"));

    }

    public static void main(String[] args) {
        chooseName(STRING_LIST,str-> "杰哥".equals(str));
    }

    private static void chooseName(List<String> strings, Predicate condition){
        strings.forEach(s -> {
            if(condition.test(s)){
                System.out.println("获取到的名字是:"+s);
            }
        });
    }





    //可以传入任意的方法
    private static void anotherMethod(Supplier<?> supplier){
        System.out.println("进入到lambda");
        //这里是执行方法
        Object o = supplier.get();
        if(o instanceof String){
            System.out.println(o);
        }
    }

    private static String simpleMethod2(String name){
        System.out.println("没有"+name);
        return name;
    }

    private static String simpleMethod(String name){
        System.out.println(name);
        return name;
    }


    private static String simpleMethod(String name,Integer age){
        System.out.println(name);
        return name;
    }
}
